<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增栏目')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal" id="form-channel-add">
			<input type="hidden" name="token" th:value="${session.token}"/>
			<input id="treeId" name="parentId" type="hidden" th:value="${channel.id}" />
			<div class="form-group">
				<label class="col-sm-3 control-label ">上级栏目：</label>
				<div class="col-sm-8">
				    <div class="input-group">
						<input class="form-control" type="text" onclick="selectChannelTree()" id="treeName" readonly="readonly" th:value="${channel.channelName}">
					    <span class="input-group-addon"><i class="fa fa-search"></i></span>
				    </div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" placeholder="请填写栏目名称" name="channelName" id="channelName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目状态：</label>
				<div class="col-sm-8">
				    <div class="radio-box" th:each="dict : ${@dict.getDict('sys_data_status')}">
						<input type="radio" th:id="${dict.id}" name="status" th:value="${dict.dictValue}" th:checked="${dict.isDefault == 'Y'}">
						<label th:for="${dict.id}" th:text="${dict.dictName}"></label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">显示顺序：</label>
				<div class="col-sm-8">
					<input class="form-control" type="number" placeholder="填写值越小越置顶" name="orderNum" required="required">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "cms/channel";
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-channel-add').serialize(), function(){
	        		$(window.parent.document).find('#btnRefresh').click();
	        	});
	        }
	    }
	
		/*栏目管理-新增-选择父栏目树*/
		function selectChannelTree() {
			var options = {
				title: '栏目选择',
				width: "380",
				url: prefix + "/selectChannelTree/" + $("#treeId").val(),
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var body = layer.getChildFrame('body', index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			layer.close(index);
		}
	</script>
</body>
</html>
